import axios from "axios";

axios.defaults.baseURL = "http://xawn.f3322.net:8012";

type LoginParams = {
  payload:payloadParams;
};

type payloadParams = {
  username:string
  password:string
}

type shopParams = {
  payload:payloadShopParams;
};

type payloadShopParams = {
  shopName:string
  tel:string
  address:string
  idCard:string
  managerName:string
  licenceNo:string
  type:string
  licenceImg:string
  idCardImg:string
}

export const login = (data:LoginParams) => {
  const {payload} = data
  console.log(payload);
  return axios({
      url:"/login",
      method:"POST",
      headers:{
          'Content-Type':'application/x-www-form-urlencoded'
      },
      data:`username=${payload.username}&password=${payload.password}`
  });
};

export const shop = (data:shopParams) =>{
  const {payload} = data
  console.log(payload);
  return axios({
      url:"/gen/apply/shop",
      method:"POST",
      headers:{
          'Content-Type':'application/x-www-form-urlencoded'
      },
      data:`shopName=${payload.shopName}&tel=${payload.tel}&address=${payload.address}&idCard=${payload.idCard}&managerName=${payload.managerName}&licenceNo=${payload.licenceNo}&type=${payload.type}&licenceImg=${payload.licenceImg}&idCardImg=${payload.idCardImg}`
      // data:{payload}
  });
}